#include "rrrotatey.h"
#include <cmath>

RRRotateY::RRRotateY()
{
    degree = 0.0f;
}

void RRRotateY::rrSetDegree(float deg)
{
    degree = deg;
}

void RRRotateY::rrRotateY(RRPrim *arg)
{
    static float d = 0.0f;
    rrSetDegree(d);
    RRVertex *vp;
    float x, z;
    int vnum;
    vnum = arg->rrGetVertsNum();
    for(int i=0; i<vnum; i++) {
        vp = arg->rrGetVertAdrs(i);
        x = vp->x * cosf(degree * 3.14159 / 180.0) + vp->z * sinf(degree * 3.14159 / 180.0);
        z = vp->z * cosf(degree * 3.14159 / 180.0) - vp->x * sinf(degree * 3.14159 / 180.0);
        vp->x = x;
        vp->z = z;
    }
    d += 1.0f;
}
